<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/pages/common/header.jsp"%>
</head>
<body>
	<div class="contentBody contentborder">
		<div class="tab-pane" id="tabPane">
			<div id="message"><%=message %></div>
			<div class="tab-page" id="tabPage1">
				<h1 class="tab">修改密码</h1>
				<div class="contentborder tableForm">
					<jdf:form bean="entity" scope="request">
						<form name="form1" method="post" action="savePassword" onsubmit="return submitModify();">
							<input type="hidden" name="loginName" value="<%=session.getAttribute(SecurityConstants.LOGIN_NAME)%>" />
							<table class="inputTable">
							    <tr>
									<td nowrap class="label cancelBorderLeft">
										<label for="oldPassword">旧密码:</label>
									</td>
									<td class="content">
										<input name="oldPassword" type="password"/>
									</td>
									<td nowrap class="label">
										<label for="newPassword">新密码:</label>
									</td>
									<td class="content">
										<input name="newPassword" type="password"/>
									</td>
								</tr>
								<tr>
									<td nowrap class="label cancelBorderLeft">
										<label for="confirmPassword">再确认:</label>
									</td>
									<td class="content" colspan="3">
										<input name="confirmPassword" type="password"/>
									</td>
								</tr>
								<tr>
									<td class="bottomLabel" nowrap colspan="4">
										<div class="right">
											<button type="submit">提交</button>
										</div>
									</td>
								</tr>
							</table>
						</form>
					</jdf:form>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		<!--
		function fIsNumber (sV,sR){
			var sTmp;
			if(sV.length==0){
				return (false);
			}
			for (var i=0; i < sV.length; i++){
	  			sTmp= sV.substring (i, i+1);
		  		if (sR.indexOf (sTmp, 0)==-1) {
			  		return (false);
			  	}
			}
			return (true);
		}

		function fIsMulti(sp) {
			var num=0;
			var zm=0;
			for(var i=0; i<sp.length; i++){
		  		if(fIsNumber(sp.charAt(i),"1234567890")!=1 ){
		    		num++;
		  		}else{
		    		zm++;
		  		}
			}
			if(num==sp.length||zm==sp.length){
	   			return false;
			}
			return true;
		}

		//验证密码中是否包含用户名
		function validatePassword(){
			var userName = document.form1.userName.value;
			var newPassword = document.form1.newPassword.value;
			//判断用户名是否存在密码中
			if (newPassword.indexOf(userName) > -1){
				return false;
			}
			return true;
		}
		function submitModify(){
	 		if (document.form1.newPassword.value!=document.form1.confirmPassword.value){
	   			alert("两次密码不匹配，请重新输入!");
	   			return false;
	 		}else if (document.form1.newPassword.value.length < 6){
	   			alert("密码必须大于6位!");
	   			return false;
	 		}else if ( fIsNumber(document.form1.newPassword.value,"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_~!@#$%^&*+=:<>?/.,;[]{}-")!=1 ){
	   			alert("您的密码应该是数字、字母、特殊军队字符,不允许出现汉字等其他字符!");
	   			return false;
	 		}else if ( fIsMulti(document.form1.newPassword.value)!=1 ){
	   			alert("您的密码必须以字母和数字混排!");
	   			return false;
	 		}else{
	  			if (validatePassword()){
		    		document.form1.action="savePassword";
		    		return true;
		  		}else{
		  			alert("密码中不能包含登陆ID");
		  			return false;
		  		}
	 		}
		}
		-->
	</script>
</body>

<%@page import="com.mvc.security.SecurityConstants"%></html>
